<% html_title l(:time_tracker_list_title) %>
<div id="time_tracker_list">

  <h2><%= l(:time_tracker_list_title) %></h2>

  <% has_zombie = false %>

  <% unless @time_trackers.nil? %>
      <div id="all-time-trackers-list">
        <% if @time_trackers.nil? || @time_trackers.is_a?(Array) && @time_trackers.empty? %>
            <p class="nodata"><%= l(:no_time_tracker) %></p>
        <% else %>
            <div class="autoscroll">
              <table class="list tt_list">
                <thead>
                <tr>
                  <th class="zombie"></th>
                  <th class="user"><%= l(:label_user) %></th>
                  <th class="project"><%= l(:time_tracker_label_project) %></th>
                  <th class="activity"><%= l(:time_tracker_label_activity) %></th>
                  <th class="start-date"><%= l(:time_tracker_label_start_date) %></th>
                  <th class="start-time"><%= l(:time_tracker_label_start_time) %></th>
                  <th class="issue"><%= l(:label_issue) %></th>
                  <th class="comments"><%= l(:time_tracker_label_comments) %></th>
                  <th class="spent-time"><%= l(:time_tracker_label_time_spent) %></th>
                  <th class="buttons"><%= l(:time_tracker_label_action) %></th>
                </tr>
                </thead>

                <tbody>
                <% @time_trackers.each do |time_tracker| %>
                    <tr id="all-timetracker<%= time_tracker.id %>" class="<%= cycle('odd', 'even') %>">
                      <% if time_tracker.zombie? %>
                          <% has_zombie = true %>
                          <td class="zombie icon icon-warning"></td>
                      <% else %>
                          <td class="zombie"></td>
                      <% end %>
                      <td class="user"><%= link_to_user help.user_from_id(time_tracker.user_id) %></td>
                      <% if time_tracker.project_id.nil? %>
                          <td class="project"></td>
                      <% else %>
                          <% project = help.project_from_id(time_tracker.project_id) %>
                          <td class="project"><%= project.nil? ? "" : link_to_project(project) %></td>
                      <% end %>
                      <% if time_tracker.activity_id.nil? %>
                          <td class="activity"></td>
                      <% else %>
                          <% activity = help.activity_from_id(time_tracker[:activity_id]) %>
                          <td class="activity"><%= project.nil? ? "" : activity.to_s %></td>
                      <% end %>
                      <td class="start-date"><%= time_tracker.get_formatted_date %></td>
                      <td class="start-time"><%= time_tracker.get_formatted_time %></td>
                      <% if time_tracker.issue_id.nil? %>
                          <td class="issue"></td>
                      <% else %>
                          <% issue = help.issue_from_id(time_tracker.issue_id) %>
                          <td class="issue"><%= issue.nil? ? "" : link_to_issue(issue, :project => true) %></td>
                      <% end %>
                      <td class="comments"><%= time_tracker.comments %></td>
                      <td class="spent-time"><%= help.time_dist2string(time_tracker.running_time / 60) %></td>
                      <td class="buttons" style="width: 75px;">
                        <% if time_tracker.user == User.current || User.current.admin? %>
                            <%= link_to l(:time_tracker_label_delete),
                                        {:controller => 'time_trackers', :action => 'delete', :id => time_tracker.id},
                                        :html => {:class => 'icon icon-del'}
                            %>
                        <% end %>
                      </td>
                    </tr>
                <% end %>
                </tbody>
              </table>
            </div>
        <% end %>
      </div>
  <% end %>

  <% if has_zombie %>
      <p class="legend icon icon-warning"><%= l(:time_tracker_zombie_legend) %></p>
  <% end %>

</div>